﻿using System;
using System.Collections.Generic;
using DevExpress.XtraEditors;
using Pharmacy.Ultilities;
using System.Windows.Forms;
using Pharmacy.ExceptionHandling;


namespace PharmacyPharnet.Core
{
    public partial class FrmEditBase : DialogViewBase
    {
        #region Declarations
        
        #endregion

        #region Constructors
        public FrmEditBase()
        {
            InitializeComponent();
        }		
        #endregion

        #region Override Methods
        
        #endregion

        #region Custom Methods

        #region Behaviours
        private Enums.ActionForm _CurrentAction = Enums.ActionForm.None;
        protected Enums.ActionForm CurrentAction
        {
            get { return _CurrentAction; }
            set {
                _CurrentAction = value;
                ChangeButtonAction(_CurrentAction);
           }
        }

        private void ChangeButtonAction(bool status)
        {
            btnNew.Enabled = !status;            
            btnDelete.Enabled = !status;
            btnCancel.Enabled = status;
            btnSave.Enabled = status;


        }
        protected virtual void ChangeButtonAction(Enums.ActionForm action)
        {
            ChangeButtonAction(action == Enums.ActionForm.Edit || action == Enums.ActionForm.New);
            _CurrentAction = action;
        }
        #endregion                      
        #endregion        

        #region Event Handlers

        private void btnClose_Click(object sender, EventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi xảy ra. Vui lòng liên hệ Người quản trị hệ thống để được hỗ trợ.");
                ExceptionHandler.LogWriter.Write(ex, ExceptionHandler.LOG_CAT_GENERAL);
                this.Close();
            }
        }
        #endregion        

		

               

    }
}